﻿<controls:ChildWindow
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" x:Class="Silverlight.SelectDatabaseDialog"
           Width="400" Height="300" 
           Title="Select Databases">
    <Grid x:Name="LayoutRoot" Margin="2">
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
        <Button x:Name="OKButton" Content="Include" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <StackPanel Orientation="Vertical">
                <TextBlock TextWrapping="Wrap" Text="Servers" FontWeight="Bold"/>
                <Grid Height="20">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="20" />
                    </Grid.ColumnDefinitions>
                    <ComboBox VerticalAlignment="Top" ItemsSource="{Binding AllServers}" DisplayMemberPath="Name" SelectedItem="{Binding SelectedServer, Mode=TwoWay}"/>
                    <Button Content="+" Grid.Column="1" Margin="4,0,0,0" Command="{Binding AddSqlServerCommand}"/>
                </Grid>
                <TextBlock TextWrapping="Wrap" Text="Databases" FontWeight="Bold"/>
            </StackPanel>
            <ListBox Grid.Row="1" ItemsSource="{Binding SelectableDatabases}">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="Foreground" Value="#FF000000" />
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate TargetType="ListBoxItem">
                                    <Grid x:Name="RootElement">
                                        <CheckBox ClickMode="Press" Content="{Binding Path=Database.Name}"
                          IsChecked="{Binding Path=Selected, Mode=TwoWay}" />
                                    </Grid>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </ListBox.ItemContainerStyle>
            </ListBox>
        </Grid>
    </Grid>
</controls:ChildWindow>